<?php
  include 'header.php';
  $pageTitle = $l_forumname;
  echo '<h2>' . $l_signout . '</h2><hr /><br />';
  $iud = $_SESSION['user_id'];
  //check if user if signed in
  if ($_SESSION['signed_in'] == true) {
      $iud = $_SESSION['user_id'];
      $sql2 = $db->query("DELETE FROM " . $table_prefix . "online_users WHERE user_id = '" . $iud . "'") or die(mysql_error());
      $time = time();
      
      $session = session_id();
      $sql1 = "INSERT INTO " . $table_prefix . "online_users(session, time, user_ip)VALUES('$session', '$time', '" . $_SERVER["REMOTE_ADDR"] . "')";
      
      setcookie('bb_auth', '', false);
      
      //unset all variables
      $_SESSION['signed_in'] = null;
      $_SESSION['user_name'] = null;
      $_SESSION['user_id'] = null;
      $_SESSION['user_level'] = null;
      $_SESSION['ok'] = null;
      $_SESSION['user_lang'] = null;
      $result = $db->query("UPDATE " . $table_prefix . "users SET user_last_login = NOW() + INTERVAL $server_time MINUTE + INTERVAL $time_difference HOUR WHERE user_id = $iud");
      header('location: signout.php');
      echo '' . $l_signout_message . '<br /> <a class="loginlink" href="index.php">' . $l_back_to . '</a>';
  } else {
      echo '<div align="center">' . $l_logout_success . ' <br /><br /><a class="loginlink" href="index.php">' . $l_back_to . '</a></div><br />';
  }
  // Get all the page's HTML into a string
  $pageContents = ob_get_contents();
  // Wipe the buffer 
  ob_end_clean();
  echo str_replace('<!--TITLE-->', $pageTitle, $pageContents);
?>